package Stringlei;

public class String6 {
    public static void main(String[] args) {
        String str1 = "I love China";
        String[] str2 = str1.split(" ");//按空格切割
        for (int i = 0; i < str2.length; i++) {
            System.out.println(str2[i]);
        }
        String str3 = "L.L.L";
        String[] str4 = str3.split(".");//单写 . 会切失败
        for (int i = 0; i < str4.length; i++) {
            System.out.println(str4[i]);//没有显示
        }
        String[] str5 = str3.split("\\.");
        for (int i = 0; i < str5.length; i++) {
            System.out.println(str5[i]);//要用\\.才能切成功
        }
    }
}
